import json

def Wlog(fileP,msg,method,addtime=True):
    import os
    import time
    fileDir = os.path.dirname(fileP)
    # 父目录不存在
    if not os.path.exists(fileDir) :
        os.makedirs(fileDir)
    if(addtime):
        nowtime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
        msg = nowtime + '=>'+ msg
    msg += '\n'
    with open(fileP,method,encoding='utf-8') as fp:
        fp.write(msg)



# 加载json配置文件
def LConf(fielPath):
    with open(fielPath,"r",encoding="utf-8") as fp:
        con = json.load(fp)
    return con
# 读取单行配置文件
def Ltxt(fielPath):
    listCon = set()
    with open (fielPath,"r",encoding="utf-8") as fp:
        line = True
        while line: 
            line = fp.readline()
            line = line.strip()
            # 如果是注释，整行都不要了
            if line == '' or '#' == line[0] : continue
            line = line.strip('\r')
            line = line.strip('\n')
            if line != '' : listCon.add(line)
    return list(listCon)
